;
; Author: Javier Quevedo Fernandez
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

;; -------------------------------------------------------------
;; -------------------------------------------------------------
;;						GESTOR DEL SENSOR
;; -------------------------------------------------------------
;; -------------------------------------------------------------

ORG	0800H
	
DELAY_1SEG:
	NOP
	RET

	
	
SENSOR_INIT:
	MOV	DIST_L,#0
	MOV	DIST_H,#0
	MOV	COUNT_OJO,#COUNT_OJO_TIME
	SETB	MEDICION_ESTADO
	CLR	MEDICION_REALIZADA
	CLR	MEDICION_PENDIENTE
	RET

	
REALIZAR_MEDICION:
	SETB	PUERTO_SENSOR
	
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	
	

	  CLR	PUERTO_SENSOR	
	JNB	MEDICION_REALIZADA,$
	CLR	MEDICION_REALIZADA
	CLR	MEDICION_PENDIENTE
	JB	MEDICION_ESTADO,RM_DELANTE
RM_DERECHA:
	MOV	DIST_DCHA_L,DIST_L
	MOV	DIST_DCHA_H,DIST_H
	LCALL	EJECUTAR_SENSOR_CENTRO
	SETB	MEDICION_ESTADO
	JMP	RM_EXIT
RM_DELANTE:
	MOV	DIST_DELANTE_L,DIST_L
	MOV	DIST_DELANTE_H,DIST_H
	LCALL	EJECUTAR_SENSOR_DERECHA
	CLR	MEDICION_ESTADO
	
RM_EXIT:	
	; CLR	PUERTO_SENSOR	
	RET
	
	
	
	